#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/wait.h>

#include "input.h"
#include "command.h"
#include "messages.h"

#include "jobs.h"
#include "stringtokenizer.h"

void print_prompt()
{
    printf("%s", "brash> " );
}

void handle_child( int i )
{
    pid_t pid = wait(NULL);
    delay_remove_job_pid( pid );
}

int main()
{
    if ( input_init() != 0 )
        exit( 1 );

    signal( SIGCHLD, handle_child );

    while ( 1 ) {
        do_remove_jobs();
        print_prompt();
        const char * command = input_read();
        command_run( command );
        input_clear();
    }

    return 0;
}
